<?php

namespace app\common\model;

/**
 * [HeartRead  一心专念表]
 * @author [C。]
 * @return html
 */
class HeartRead extends Base
{
    protected $name = 'heart_read';
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlist($map,$from = 0, $size = 5)
    {
        $join = [
            ['app_member m','m.id = h.mid'],
        ];
        $order = ['h.id' => 'desc'];
        $result =  $this->field('h.id,h.starttime,h.endtime,h.type,m.username,m.tel,m.img')
            ->alias('h')
            ->join($join)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();
        return $result;
    }
    /**
     * 根据条件获取总数
     * @param array $param
     */
    public function getCount($map) {
        $join = [
            ['app_member m','m.id = h.mid'],
        ];
        $result =  $this
            ->alias('h')
            ->join($join)
            ->where($map)
            ->count();
        return $result;
    }
    /**
     * 根据条件获取总数
     * @param array $param
     */
    public function getPerson($map){
        $result =  $this->where($map)->distinct(true)->field('mid')->select();
        return $result;
    }
}